package edu.ptu.acl.dto.param;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

@Data
public class UserParam {
    @Min(value = 10000000000000000L,message = "id不规范" ,groups = Update.class)
    private Long id;

    @NotBlank(message = "用户手机号不能为空",groups = {Update.class,Save.class})
    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$",message = "请输入正确的手机号",groups = {Update.class,Save.class})
    private String telephone;

    @NotBlank(message = "用户名不能为空",groups = {Update.class,Save.class})
    @Length(min = 1,max = 20,message = "用户名长度必须是1-20个字符",groups = {Update.class,Save.class})
    private String name;

    @NotBlank(message = "用户邮箱不能为空",groups = {Update.class,Save.class})
    @Email(message = "邮箱格式不正确",groups = {Update.class,Save.class})
    private String email;

    @NotNull(message = "所属部门不能为空",groups = {Update.class,Save.class})
    private Long deptId;

    @NotBlank(message = "状态不能为空",groups = {Update.class,Save.class})
    @Pattern(regexp = "[10]",message = "状态异常",groups = {Update.class,Save.class})
    private String status;

    @NotNull(message = "乐观锁版本不能为空" ,groups = {Update.class})
    private Integer version;

    /**
     * 保存的时候校验分组
     */
    public interface Save {
    }

    /**
     * 更新的时候校验分组
     */
    public interface Update {
    }

}
